package cn.itcast.entity;


import lombok.Data;

@Data
public class ValidResult<T> {
    private boolean success;
    private String message;
    private T data;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ValidResult() {
        this.success = true;
        this.message = "success";
    }

    public ValidResult(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public ValidResult(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    /**
     * 是否有错误
     * @return
     */
    public boolean hasError() {
        return !success;
    }
}
